<template>
  <div class="share">
    <x-header :left-options="{backText: ''}">邀请好友</x-header>
    <div>
      <input id="foo" :value="shareLinkUrl" style="border:none;outline: none;color:#5b29cc;font-size:20px;margin-top:30px;width: 100%"
        readonly>
    </div>
    <div class="shareBg">
      <div class="shareRecord">
        <div class="shareRecord-top fr">
          <span>我的邀请记录</span>
          <!-- <span class="fa fr25 color51">提现</span> -->
        </div>
        <div class="shareRecord-center fr">
          <span class="color51 shareNum1 fa">成功邀请(人)</span>
          <span class="color51 shareNum2 fa">累计返现(元)</span>
          <div>
            <span class="color51 shareMoney1">{{person}}</span>
            <span class="color51 shareMoney2">{{moneys}}</span>
          </div>
        </div>
      </div>
      <!-- <div class="shareLink">
        <div class="outerBorder fr">
          <img src="../../assets/shareIcon.png" alt="" class="fa" width="180" style="left: 25%;top: -10px;">
          <span class="fa whiteColor" style="left: 39%;top: -7px;font-size: 20px;">邀请链接</span>
          <div class="innerBorder" style="overflow-x: scroll;">
            <div style="width: 500px;">
              <input id="foo" :value="shareLinkUrl" style="border:none;outline: none;color:#5b29cc;font-size:20px;margin-top:30px;width: 100%"
                readonly>
            </div>
            <div class="copyBtnBg">
              <copy :show="true" :value="11" :text="'复制'" :id="'#foo'"></copy>
            </div>
          </div>
        </div>
      </div> -->
      <div class="shareRule">
        <div class="outerBorder fr">
          <img src="../../assets/shareIcon.png" alt="" class="fa" width="180" style="left: 25%;top: -10px;">
          <span class="fa whiteColor" style="left: 39%;top: -7px;font-size: 20px;">邀请规则</span>
          <div class="innerBorder">
            <div>1.分享邀请链接，邀请好友注册</div>
            <div>2.好友注册完成后邀请人与被邀请人各得20元满减券</div>
            <div>3.被邀请人完成首次投资后，邀请人与被邀请人将各自获得投资本金(不含优惠券)的2%返现。</div>
          </div>
        </div>
      </div>
      <div class="shareRule">
        <div class="outerBorder fr" style="height: 430px;">
          <img src="../../assets/shareIcon.png" alt="" class="fa" width="180" style="left: 25%;top: -10px;">
          <span class="fa whiteColor" style="left: 39%;top: -7px;font-size: 20px;">奖励规则</span>
          <div class="innerBorder" style="height: 410px;">
            <div>1.邀请好友购买OTC套利新月产品,即可获得其首次入金额
              <span style="color:#ff1010">0.2%</span>的奖励</div>
            <div>2.邀请好友购买OTC套利一季产品,即可获得其首次入金额
              <span style="color:#ff1010">0.9%</span>的奖励</div>
            <div>3.邀请好友购买OTC套利半年产品,即可获得其首次入金额
              <span style="color:#ff1010">1.9%</span>的奖励</div>
            <div>4.邀请好友购买OTC套利全年产品,即可获得其首次入金额
              <span style="color:#ff1010">4%</span>的奖励</div>
            <div>5.邀请好友购买ETF基金产品,即可获得其首次入金额
              <span style="color:#ff1010">4%</span>的奖励</div>
            <div>6.邀请好友购买ICO,即可获得其首次入金额
              <span style="color:#ff1010">4%</span>的奖励</div>
            <div style="color:#ff1010;margin-top: 20px;">注意:邀请人必须实名认证,便于每个月打款信息审核推荐奖励情况</div>
          </div>
        </div>
      </div>
      <div class="shareLink" style="margin-top:270px;">
        <div class="outerBorder fr">
          <img src="../../assets/shareIcon.png" alt="" class="fa" width="180" style="left: 25%;top: -10px;">
          <span class="fa whiteColor" style="left: 39%;top: -7px;font-size: 20px;">奖励情况</span>
          <div class="innerBorder color51" style="height: 140px; ;padding-top: 30px;">
            <div>邀请人本月的奖励金可在下个月的20日领取</div>
            <div>例如:5月1-5月30日邀请金为8000元,在6月20日可以进行8000元的提取。提取到账时间为1-3个工作日提取</div>
          </div>
        </div>
      </div>
      <div class="shareRule" style="margin-bottom:50px;">
        <div class="outerBorder fr">
          <img src="../../assets/shareIcon.png" alt="" class="fa" width="180" style="left: 25%;top: -10px;">
          <span class="fa whiteColor" style="left: 39%;top: -7px;font-size: 20px;">邀请记录</span>
          <div class="innerBorder color51">
            <div style="margin-top:30px;" class="fr">
              <ul class="shareRecordDet">
                <li>好友手机号</li>
                <li>注册时间</li>
                <li>奖励金额</li>
                <div style="clear: both;"></div>
              </ul>
              <ul class="shareRecordDetail" style="height: 110px;overflow: auto;">
                <div :style="{height:40*list.length+'px'}">
                  <div v-for="listNam in list">
                    <li>{{listNam.userid|formatPhone}}</li>
                    <li>{{listNam.created |formatDate}}</li>
                    <li @click="putForward(listNam.orderid)">
                      <span class="moneyShare">¥{{listNam.money}}</span>
                    </li>
                    <div style="clear: both;"></div>
                  </div>
                </div>
              </ul>
            </div>
          </div>
        </div>
      </div>
      <div class="shareFriend" @click="showTips=true" v-if="!showTips">
        送好友大福利>
      </div>
    </div>



    <!-- 分享弹框 -->
    <div class="shareTips" v-show="showTips">
      <div class="shareBox">
        <div style="height: 150px;padding: 10px;">
          <span>分享给好友</span>
          <div style="display: flex">
            <div style="flex: 1" v-show="isNative">微信好友</div>
            <div style="flex: 1" v-show="isNative">朋友圈</div>
            <div style="flex: 1">
              <copy :show="true" :value="11" :text="'复制链接'" :id="'#foo'"></copy>
            </div>
          </div>
        </div>
        <div class="cancelBtn" v-show="showTips" @click="showTips=false">
          取消
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import {
    XHeader
  } from 'vux'
  import Copy from '../../components/common/copy.vue'
  import http from '../../service/http.js'
  import tips from '../../service/tips.js'
  import util from '../../service/util.js'
  export default {
    data() {
      return {
        person: "",
        moneys: "",
        list: [],
        shareLinkUrl: "",
        username: "",
        showTips: false,
        isNative:false,//判断是不是原生
      }
    },
    mounted() {
      this.username = this.$route.query.username || util.getItem('login.username');
      if(this.$route.query.username){
        this.isNative=true;
      }
      this.getShare();
      this.shareLinkUrl = "http://app.bit000.com/#/login?username=" + this.username
    },
    methods: {
      // 提现
      putForward(orderid) {
        http.post("/invite/cash", {
          orderid: orderid,
          username: this.username
        }).then((res) => {
          if (res.data.status == 200) {
            tips.tips(res.data.msg)
          } else {
            tips.tips(res.data.msg)
          }
        }).catch((res) => {
          tips.tips(res.data.msg)
        })
      },
      getShare() {
        http.get("/invite/invited?username=" + this.username).then((res) => {
          if (res.status == 200) {
            this.person = res.data.body.person;
            this.moneys = res.data.body.moneys;
            this.list = res.data.body.list;
          }
        })
      }
    },
    components: {
      XHeader,
      Copy
    }
  }
</script>
<style lang="less">
  .copy {
    width: 100%;
    display: block;
  }

  .c9 {
    color: #999;
  }

  .color51 {
    color: #5b29cc;
  }

  .fa {
    position: absolute;
  }

  .fr {
    position: relative;
  }

  .fr15 {
    right: 15px;
  }

  .fr25 {
    right: 25px;
  }

  .t20 {
    top: 20px;
  }

  .whiteColor {
    color: #fff;
  }

  .t10 {
    top: 10px;
  }

  .mT10 {
    margin-top: 10px;
  }

  .middle {
    vertical-align: middle;
  }

  .mt15 {
    margin-top: 15px;
  }

  .mgL8 {
    margin-left: 8px;
  }

  .mgb15 {
    margin-bottom: 15px;
  }

  .mgT5 {
    margin-top: 5px;
  }

  .share .copyBtn {
    color: #fff;
    background: linear-gradient(left, #fedd32, #fe9f0a);
    display: inline-block;
    width: 50px;
    text-align: center;
    height: 20px;
    line-height: 20px;
    font-size: 13px;
    top: 12px;
  }

  .share .helpLower {
    transition: all 0.5s;
    transform: rotate(180deg);
  }

  .share .bankMoney {
    border: none;
    outline: none;
    text-align: right;
    display: inline-block;
    height: 45px;
    width: 70%;
    font-size: 15px;
  }

  .share .vux-header {
    background: #fff;
    position: fixed;
    width: 100%;
    z-index: 888;
  }

  .share .vux-header .vux-header-title {
    line-height: 40px;
    text-align: center;
    font-size: 18px;
    font-weight: 400;
    color: #000;
  }

  .share .vux-header .vux-header-left .left-arrow:before {
    content: "";
    position: absolute;
    width: 12px;
    height: 12px;
    border: 1px solid #000;
    border-width: 1px 0 0 1px;
    -webkit-transform: rotate(315deg);
    transform: rotate(315deg);
    top: 8px;
    left: 7px;
  }

  .shareBg {
    position: absolute;
    width: 100%;
    background-image: url('../../assets/shareBg.png');
    background-size: 100% 100%;
    background-position: center 0;
    margin-top: -10px;
  }

  .share .shareRecord {
    margin-top: 260px;
    padding: 15px;
    color: #fff;
    border-radius: 25px;
  }

  .shareRecord-top {
    height: 40px;
    line-height: 40px;
    background: #fbe26a;
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    padding-left: 25px;
  }

  .shareRecord-center {
    background: #fff;
    height: 130px;
    border-bottom-left-radius: 25px;
    border-bottom-right-radius: 25px;
  }

  .share .shareNum1 {
    top: 30px;
    left: 45px;
  }

  .share .shareNum2 {
    top: 30px;
    right: 45px;
  }

  .share .shareMoney1 {
    position: absolute;
    width: 80px;
    text-align: center;
    display: inline-block;
    top: 60px;
    left: 45px;
    font-size: 30px;
  }

  .share .shareMoney2 {
    position: absolute;
    width: 110px;
    text-align: center;
    display: inline-block;
    top: 60px;
    right: 45px;
    font-size: 30px;
  }

  .share .shareLink {
    margin-top: 60px;
    padding: 15px;
  }

  .share .outerBorder {
    height: 170px;
    background: #b4aaf0;
    border-radius: 25px;
    padding: 10px;
  }

  .share .shareLink .innerBorder {
    background: #fff;
    height: 170px;
    border-radius: 25px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .share .shareLink .copyBtnBg {
    width: 150px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    color: #fff;
    background: #fbe26a;
    margin: auto;
    margin-top: 50px;
    border-radius: 25px;
  }

  .share .shareRule {
    padding: 15px;
    margin-top: 50px;
    height: 220px;
    color: #5b29cc;
  }

  .share .shareRule .outerBorder {
    height: 220px;
  }

  .share .shareRule .innerBorder {
    background: #fff;
    height: 200px;
    border-radius: 25px;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 20px;
  }

  .share .shareRecordDet li {
    float: left;
    list-style: none;
    width: 33.33%;
    text-align: center;
    border-bottom: 1px dashed #5b29cc;
    height: 40px;
  }

  /* .share .shareRecordDetail {
    margin-top: 20px;
  } */

  .share .shareRecordDetail li {
    float: left;
    list-style: none;
    width: 33.33%;
    text-align: center;
    height: 40px;
    line-height: 40px;
  }

  .moneyShare {
    background: #5b29cc;
    color: #fff;
    border-radius: 5px;
    padding-left: 10px;
    padding-right: 10px;
    min-width: 65px;
    display: inline-block;
    height: 20px;
    line-height: 20px;
  }

  .shareTips {
    position: fixed;
    left: 0px;
    right: 0px;
    bottom: 0px;
    top: 0px;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
  }

  .cancelBtn {
    width: 100%;
    background: #fff;
    text-align: center;
  }

  .shareBox {
    position: absolute;
    position: absolute;
    bottom: 0px;
    width: 100%;
    height: 200px;
    background: #fff;
    transition: all 1s;
  }

  /* .transitionBox {
    bottom: 0px !important;
    transition: all 1s;
  } */

  .shareFriend {
    position: fixed;
    bottom: 0px;
    background: #fff;
    width: 100%;
    text-align: center;
    height: 40px;
    line-height: 40px;
  }
</style>